package com.bhs.sansonglogistics.utils;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.webkit.JavascriptInterface;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.net.Config;

public class JavaScriptObject {

    private String url;
    private Context context;
    private String deliver_sn;

    public JavaScriptObject(Context context, String url, String deliver_sn) {
        this.url = url;
        this.context = context;
        this.deliver_sn = deliver_sn;
    }

    @JavascriptInterface
    public void share(String name, String company_pic) {
        LogUtils.d("share" + name + company_pic);
        Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.mipmap.logo5);
        WxShareUtils.shareWeb(context, url, "电子面单", name, bmp);
    }

    @JavascriptInterface
    public void download() {
        LogUtils.d("download");
        String url = Config.agreementUrl + "index?type=android&hiden=false&down=true&deliver_sn=" + deliver_sn;
        //String url = "http://192.168.1.21:8080/#/?deliver_sn=SS2310310000004&type=android&hiden=false&down=true";
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        context.startActivity(intent);
    }
}
